import React from 'react'
import ChatDeviceModelCalculate from '../ChatDeviceModelCalculate'
import ChatParaModelCalculate from '../ChatParaModelCalculate'
import ChatOptCalculate from '../ChatOptCalculate'
import ViewReport from './viewReport'
import useSequentialLoader from '@/utils/hooks/useSequentialLoader'
import './index.less'
interface IProps {
    data: any;
    loading: boolean;
    onRender?: (isForce?: boolean) => void;
}

const ChatBottleneckAnalysis: React.FC<Omit<IProps, 'type'>> = ({ data, loading, onRender }) => {
    const loadedComponents = useSequentialLoader([
        {
            component: ChatOptCalculate,
            effectKey: 'optCalResult',
            // skipFn: (originData: any) => {
            //     return originData.optCalResult && Object.keys(originData.optCalResult).length === 0
            // }
        },
        {
            component: ChatParaModelCalculate,
            effectKey: 'parameterBottleneckResult',
        },
        {
            component: ChatDeviceModelCalculate,
            effectKey: 'deviceBottleneckResult',
        },
        {
            component: ViewReport,
            effectKey: 'optCalResult'
        },
    ], data, {
        onLoad: () => {
            onRender && onRender(true)
        },
        onEnd: () => {
            onRender && onRender(true)
        }
    }, {
        loading: loading,
        autoRender: true
    }, {
        onRender,
    })
    return (
        <div className='chat-bottle-report'>
            {loadedComponents}
        </div>
    )
}

export default ChatBottleneckAnalysis
